module.exports = (app)=>{
    const express = require('express');
    const router = express.Router();
    //导入multer模块处理上传的图片
    const multer = require('multer');
    const upload = multer({ dest: __dirname + '/../../uploads' });
    const {
        UserAddMiddleWare,
        UserLoginMiddleWare,
        UserSearchByIdMiddleWare,
        UserHoursePicMiddleWare,
        UserAddHourseMiddleWare,
        UserSelectAllHourseMiddleWare,
        SelectHourseByUserIdAndHourseIdMiddleWare,
        updateHourseByTwoIdMiddleWare,
        deleteHourseByHourseIdMiddleWare,
        selectAllHourseMiddleWare,
        GetAllUserMiddleWare,
        updateUserPermissionByUserIdMiddleWare,
        selectHourseByHidMiddleWare,
        selectHoursesByHNameMiddleWare,
        selectHoursesByhuxinMiddleWare,
        selectHoursesBymodelMiddleWare,
        selectHoursesByDirectionMiddleWare,
        selectHoursesByDecorateMiddleWare} = require('../../middleware/user');

    router.post('/add',UserAddMiddleWare);
    router.post('/login',UserLoginMiddleWare);
    router.get('/user/:id',UserSearchByIdMiddleWare);
    router.post('/uploadimg', upload.single('file'), UserHoursePicMiddleWare);
    router.post('/addhourse',UserAddHourseMiddleWare);
    router.get('/selecthourselist/:id',UserSelectAllHourseMiddleWare);
    router.post('/selecthoursebytwoid',SelectHourseByUserIdAndHourseIdMiddleWare);
    router.post('/updatehourse',updateHourseByTwoIdMiddleWare);
    router.get('/deletehourse/:id',deleteHourseByHourseIdMiddleWare);
    router.get('/selectallhourse',selectAllHourseMiddleWare);
    router.get('/getalluser',GetAllUserMiddleWare);
    router.post('/changepermissions',updateUserPermissionByUserIdMiddleWare);
    router.get('/selecthourse/:id',selectHourseByHidMiddleWare);
    router.post('/selecthoursebyaddress',selectHoursesByHNameMiddleWare);
    router.post('/selecthoursebyhuxin',selectHoursesByhuxinMiddleWare);
    router.post('/selecthoursebymodel',selectHoursesBymodelMiddleWare);
    router.post('/selecthoursebydirection',selectHoursesByDirectionMiddleWare);
    router.post('/selecthoursebydecorate',selectHoursesByDecorateMiddleWare);
    app.use('/api/web',router);
}